/**
 * Alibaba.com.cn Inc.
 * Copyright (c) 2004-2021 All Rights Reserved.
 */
package com.starlink.common.strategy.jdnotify;

import com.starlink.common.enums.OrderStatusEnum;
import com.starlink.common.enums.OrderTypeEnum;
import com.starlink.common.strategy.JdNotify;
import com.starlink.model.domain.MallBooksOrderDO;
import com.starlink.service.MallOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author zhanghong
 * @version BookPayNotify.java, v 0.1 2024/4/11 23:02 下午 BookPayNotify Exp $$
 */
@Component
public class BookJDNotify implements JdNotify {

    @Autowired
    private MallOrderService booksOrderService;

    @Override
    public boolean supports(Integer orderType) {
        return orderType.equals(OrderTypeEnum.BOOK.getType());
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void handle(Long orderId) {
        booksOrderService.lambdaUpdate()
                .set(MallBooksOrderDO::getStatus, OrderStatusEnum.WAIT_RECEIVE.getType().toString())
                .eq(MallBooksOrderDO::getId, orderId)
                .update();
    }
}
